using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.DC.Xpo;
using DevExpress.ExpressApp.Win;
using DevExpress.ExpressApp.Xpo;
using FeatureCenter.Module;

namespace FeatureCenter.Win
{
    public partial class FeatureCenterWindowsFormsApplication : WinApplication
    {
		public FeatureCenterWindowsFormsApplication()
        {
            InitializeComponent();
        }

		private void FeatureCenterWindowsFormsApplication_DatabaseVersionMismatch(object sender, DevExpress.ExpressApp.DatabaseVersionMismatchEventArgs e)
        {
            e.Updater.Update();
            e.Handled = true;
        }

		private static FeatureCenterXpoDataStoreProvider provider;
        protected override void CreateDefaultObjectSpaceProvider(CreateCustomObjectSpaceProviderEventArgs args) {
            provider = new FeatureCenterXpoDataStoreProvider();
			args.ObjectSpaceProvider = new XPObjectSpaceProvider(provider);
            string appConnectionString = string.IsNullOrEmpty(this.ConnectionString) ? sqlConnection1.ConnectionString : this.ConnectionString;
            provider.Initialize(
                string.Format(@"XpoProvider=InMemoryDataStore; Read Only=True; Data Source={0}nwind.xml", AppDomain.CurrentDomain.SetupInformation.ApplicationBase),
                appConnectionString);
		}
        // You can also localize or customize built-in XAF status messages by overriding the XafApplication.UpdateStatus method (test the Context parameter with the DevExpress.ExpressApp.Localization.ApplicationStatusMesssageId enumeration value).
		public override void UpdateStatus(string context, string title, string message, params object[] additionalParams) {
            bool localizableDemoFlag = false;
            if(localizableDemoFlag) {
                if(context == DevExpress.ExpressApp.Localization.ApplicationStatusMesssageId.ApplicationSetupStarted.ToString()) {
                    title = "My localized title";
                    message = "My localized message";
                }
            }
			base.UpdateStatus(context, title, message, additionalParams);
        }
	}
}
